package test.itachi;


import java.math.BigInteger;
import java.util.ArrayList;

public class Main {

    public static void main(String[] args) {
        String testStr = "B718091800215E3A004276900003114001000000000000000000000000000000000000000000000000000966670000";
        byte[] bytes = HexUtil.hexStringToBytes(testStr);
        CrcCalculator calculator = new CrcCalculator(Crc16.Params[Crc16.Params.length-1]);
        long result = calculator.calc(bytes, 0, bytes.length);
        System.out.println(calculator.Parameters.Name + " - BAD ALGO!!! " + Long.toHexString(result).toUpperCase());
    }

    public static synchronized BigInteger bigNumber(int num) {//利用BigInteger类计算阶乘
        ArrayList list = new ArrayList();//创建集合数组
        list.add(BigInteger.valueOf(1));//往数组里添加一个数值
        for (int i = list.size(); i <= num; i++) {
            BigInteger lastfact = (BigInteger) list.get(i - 1);//获得第一个元素

            BigInteger nextfact = lastfact.multiply(BigInteger.valueOf(i));//获得下一个数组

            list.add(nextfact);

        }

        return (BigInteger) list.get(num);//返回数组中的下标为num的值
    }


    private static void Check(AlgoParams[] params) {




    }
}